import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import com.RspInterface 1.0


//资金与风险信息
//不知道为什么第一次显示会向右偏很多
Item {
    property RspInterface custDetail
    property string cust: ""
    property string branch: ""
    property string cust_type: ""
    property string mobile_phone: ""
    property string curr_can_use: ""
    property string margin_mem: ""
    property string margin_exch: ""
    property string margin_total: ""
    property string surplus: ""
    property string f_in_out_bal: ""
    property string risk_deg1: ""
    property string risk_deg2: ""
    property string risk_grade_id: ""
    property string debt_call: ""
    property string risk_deg_yda: ""
    property string qryTime: ""
    property int rowCount: 6
    //第三列调整高度
    property int thirdColumnTopMargin: 5

    //    RowLayout {
    //        anchors.fill: parent
    //        anchors.margins: 5
    ColumnLayout {
        anchors.left: parent.left
        anchors.leftMargin: 10
        anchors.top: parent.top
        anchors.topMargin: 5
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 5
        anchors.right: parent.right
        anchors.rightMargin: (parent.width * 2 / 3) + 50
        //            spacing: 5
        NameValue {
            name: "客户" + colon
            value: cust
            Layout.alignment: Qt.AlignCenter
            //                Layout.preferredHeight: parent.height / rowCount
        }
        NameValue {
            name: "代理机构" + colon
            value: branch
            Layout.alignment: Qt.AlignCenter
            //                Layout.preferredHeight: parent.height / rowCount
        }
        NameValue {
            name: "客户级别" + colon
            value: cust_type
            Layout.alignment: Qt.AlignCenter
            //                Layout.preferredHeight: parent.height / rowCount
        }
        NameValue {
            name: "联系方式" + colon
            value: mobile_phone
            Layout.alignment: Qt.AlignCenter
            //                Layout.preferredHeight: parent.height / rowCount
        }
        NameValue {
            name: "风控可用" + colon
            value: curr_can_use
            Layout.alignment: Qt.AlignCenter
            //                Layout.preferredHeight: parent.height / rowCount
        }
        NameValue {
            name: "浮动盈亏" + colon
            value: surplus
            Layout.alignment: Qt.AlignCenter
        }
    }
    ColumnLayout {
        anchors.top: parent.top
        anchors.topMargin: 5
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 5
        anchors.right: parent.right
        anchors.rightMargin: (parent.width / 3) + 5
        anchors.left: parent.left
        anchors.leftMargin: (parent.width / 3) + 50
        NameValue {
            name: "会员保证金" + colon
            value: margin_mem
            Layout.alignment: Qt.AlignCenter
        }
        NameValue {
            name: "交易所保证金" + colon
            value: margin_exch
            Layout.alignment: Qt.AlignCenter
        }
        NameValue {
            name: "总保证金" + colon
            value: margin_total
            Layout.alignment: Qt.AlignCenter
        }

        NameValue {
            name: "当日出入金" + colon
            value: f_in_out_bal
            Layout.alignment: Qt.AlignCenter
        }
        NameValue {
            name: "风险度1" + colon
            value: risk_deg1
            Layout.alignment: Qt.AlignCenter
        }
        NameValue {
            name: "风险度2" + colon
            value: risk_deg2
            Layout.alignment: Qt.AlignCenter
        }
    }
    ColumnLayout {
        anchors.top: parent.top
        anchors.topMargin: thirdColumnTopMargin
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 5
        anchors.right: parent.right
        anchors.rightMargin: 5
        anchors.left: parent.left
        anchors.leftMargin: (parent.width * 2 / 3) + 5

        NameValue {
            name: "风险等级" + colon
            value: risk_grade_id
            Layout.alignment: Qt.AlignCenter
        }
        NameValue {
            name: "追保金额" + colon
            value: debt_call
            Layout.alignment: Qt.AlignCenter
        }
        NameValue {
            name: "上日等级" + colon
            value: risk_deg_yda
            Layout.alignment: Qt.AlignCenter
        }
        NameValue {
            name: "刷新时间" + colon
            value: qryTime
            Layout.alignment: Qt.AlignCenter
        }
    }

    //    }
    onCustDetailChanged: {
        console.log("onCustDetailChanged")
        if (custDetail.get("acct_no") !== "") {
            cust = "[" + custDetail.get("acct_no") + "]" + custDetail.get(
                        "cust_abbr")
            branch = "[" + custDetail.get("branch_id") + "]" + custDetail.get(
                        "branch_name")
            cust_type = custDetail.get("cust_type")
            mobile_phone = custDetail.get("mobile_phone")
            curr_can_use = custDetail.get("curr_can_use")
            margin_mem = custDetail.get("margin_mem")
            margin_exch = custDetail.get("margin_exch")
            margin_total = custDetail.get("margin_total")
            surplus = custDetail.get("surplus")
            f_in_out_bal = custDetail.get("f_in_out_bal")
            risk_deg1 = custDetail.get("risk_deg1")
            risk_deg2 = custDetail.get("risk_deg2")
            risk_grade_id = custDetail.get("risk_grade_id")
            debt_call = custDetail.get("debt_call")
            risk_deg_yda = custDetail.get("risk_deg_yda")
            qryTime = custDetail.get("in_out_bal_tm")
        } else {
            cust = ""
            branch = ""
            cust_type = ""
            mobile_phone = ""
            curr_can_use = ""
            margin_mem = ""
            margin_exch = ""
            margin_total = ""
            surplus = ""
            f_in_out_bal = ""
            risk_deg1 = ""
            risk_deg2 = ""
            risk_grade_id = ""
            debt_call = ""
            risk_deg_yda = ""
            qryTime = ""
        }
    }
}
